home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amoszine 3
/
Amoszine 3.adf
/
Celebrity_source
/
amal_ball_bounce.AMOS
/
amal_ball_bounce.amosSourceCode
next >
Wrap
AMOS Source Code
|
1992-02-26
|
5KB
|
162 lines
' ********************************************************************
'
' Amal Ball Bounce
'
' - ** By Paul Nordovics ** -
'
' ********************************************************************
'
' Explanation:
'
' Each Ball Is Given An Amal Channel Which Moves It Around The Screen
' The AMAL Internal Registers R0 to R7 Are Used As Follows:
' R0 = Ball Direction
' When R0=0 The Ball Direction Is Up/Right
' When R0=1 The Ball Direction Is Down/Right
' When R0=2 The Ball Direction Is Down/Left
' When R0=3 The Ball Direction Is Up/Left
' R2 \
' R3 \ These Are Used To Work Out How Far Ball
' R4 / Can Move Before Hitting Screen Edge
' R5 /
' R6 = Distance Ball Will Move Before Hitting Screen Edge
' R7 = Ball Speed
'
' ********************************************************************
'
' *************
' Set up screen
' *************
Screen Open 0,320,256,4,Lowres : Rem Not Many Colours So It Works Faster
Curs Off : Flash Off : Hide
Get Sprite Palette
Cls 0
Double Buffer : Rem Prevents Balls From Flickering
Autoback 0 : Rem Disables Automatic Screen Switching
Bob Update Off : Rem Disables Automatic Bob Update
'
' ******************
' Start Of Amal Loop
' ******************
' ********************
' Work Out R2,R3,R4,R5
' ********************
A$="A:Let R2=311-X;"
A$=A$+"Let R3=X-8;"
A$=A$+"Let R4=Y-8;"
A$=A$+"Let R5=247-Y;"
'
' *********************************************
' This Bit Gets The Direction Of Ball And Jumps
' To The Appropriate Part Of The Next Section
' *********************************************
A$=A$+"If R0=0 Jump B;"
A$=A$+"If R0=1 Jump C;"
A$=A$+"If R0=2 Jump D;"
A$=A$+"If R0=3 Jump E;"
'
' ************************************************
' This Bit Works Out Which Axis Of Screen Edge The
' Ball Will Reach First i.e horizontal or vertical
' ************************************************
' ********
' Up/Right
' ********
A$=A$+"B: If R2<R4 Jump F; Jump G;"
' **********
' Down/Right
' **********
A$=A$+"C: If R2<R5 Jump H; Jump I;"
' *********
' Down/Left
' *********
A$=A$+"D: If R3<R5 Jump J; Jump K;"
' *******
' Up/Left
' *******
A$=A$+"E: If R3<R4 Jump L; Jump M;"
'
' ************************************************************
' This Bit Moves The Ball And Sets A New Direction When Screen
' Edge Is Reached.We Then Go Back To The Begining Of AMAL Loop
' ************************************************************
A$=A$+"F: Let R6=R2; M R6,0-R6,R6/R7; Let R0=3; Pause; Jump A;"
A$=A$+"G: Let R6=R4; M R6,0-R6,R6/R7; Let R0=1; Pause; Jump A;"
A$=A$+"H: Let R6=R2; M R6,R6,R6/R7; Let R0=2; Pause; Jump A;"
A$=A$+"I: Let R6=R5; M R6,R6,R6/R7; Let R0=0; Pause; Jump A;"
A$=A$+"J: Let R6=R3; M 0-R6,R6,R6/R7; Let R0=1; Pause; Jump A;"
A$=A$+"K: Let R6=R5; M 0-R6,R6,R6/R7; Let R0=3; Pause; Jump A;"
A$=A$+"L: Let R6=R3; M 0-R6,0-R6,R6/R7; Let R0=0; Pause; Jump A;"
A$=A$+"M: Let R6=R4; M 0-R6,0-R6,R6/R7; Let R0=2; Pause; Jump A;"
'
' *************************************************************
' The Number Of Balls Can Range From 1 to 64
' Values 1 to 16 Will Allow The Program To Run Using Interrupts
' A Value Of 64 Will Cause Your Computer To Have a Fit!!!
' *************************************************************
NUMBER_OF_BALLS=16
'
' ********************************************************
' If There Are More Than 16 Balls We Have To Turn Off The
' Interrupts In Order To Have More Amal Channels Available
' ********************************************************
If NUMBER_OF_BALLS>16
Synchro Off
End If
'
' ************************************************************
' We Then Set Up The AMAL Channels And Assign One To Each Ball
' ************************************************************
For COUNT=0 To NUMBER_OF_BALLS-1
' *****************
' Ball colour (1-3)
' *****************
BALL_COLOUR=Rnd(2)+1
'
' ***********************************
' This Gives The Ball An Amal Channel
' ***********************************
Bob COUNT,Rnd(319),Rnd(255),BALL_COLOUR
Channel COUNT To Bob COUNT
Amal COUNT,A$
'
' ********************
' Ball direction (0-3)
' ********************
Amreg(COUNT,0)=Rnd(3)
'
' **********
' Ball speed
' **********
Amreg(COUNT,7)=Rnd(2)+1
'
' **************************************************
' This Prevents The Background From Behind Each Ball
' From Being Saved - Makes Things A Little Faster
' **************************************************
Set Bob COUNT,-1,,
Next COUNT
'
' ********************
' This Sets It All Off
' ********************
Amal On
If NUMBER_OF_BALLS>16
Synchro On
End If
'
' ************************************************
' Un-Rem This And See What Happens!
' Works Best If You Give All Balls The Same Colour
' ************************************************
'Shift Up 50,1,3,1
'
' ******************************************
' Simple Loop So We Can See The Balls Moving
' ******************************************
Do
Wait Vbl
Bob Clear
Bob Draw
Screen Swap
Loop